Skip to content

feat: AUS Perps Watchlist#9010

Open
gambinish wants to merge 8 commits into
mainfrom
perps/tat-2663-migrate-perps-watchlist-to-aus
Open

feat: AUS Perps Watchlist#9010
gambinish wants to merge 8 commits into
mainfrom
perps/tat-2663-migrate-perps-watchlist-to-aus

Conversation

@gambinish

@gambinish gambinish commented Jun 4, 2026

Copy link
Copy Markdown
Member

Explanation

Persists state.watchlistMarkets to AUS so the watchlist follows the user across devices and clients, rather than being device-local only.

What changed

  • toggleWatchlistMarket now performs an optimistic local update first (UI is instant), then syncs to AUS. If the remote write fails, local state is reverted.
  • On init(), the controller hydrates state.watchlistMarkets from AUS. AUS is the source of truth; local state acts as an offline cache (persist: true unchanged).
  • One-time migration: if a user already has local markets saved but no AUS record yet, those are pushed up automatically on first init.
  • Falls back to local-only silently when unauthenticated or when the active provider has no AUS mapping (e.g. aggregated).
  • Adds resolveWatchlistExchangeKey() — the single extension point for adding future DEX providers to AUS sync.
    Integration (client PRs)

Each client needs to grant the PerpsController messenger two new allowed actions:

  • AuthenticatedUserStorageService:getNotificationPreferences
  • AuthenticatedUserStorageService:putNotificationPreferences

No other wiring needed — AuthenticatedUserStorageService is already running wherever NotificationServicesController is wired, and AuthenticationController:getBearerToken was already allowed.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Introduces cross-device preference writes via read-merge-PUT on the shared notification preferences blob and a breaking async API on toggleWatchlistMarket; mitigations include optimistic UI with revert, silent local fallback, and broad test coverage.

Overview
Perps watchlists are now synced to Authenticated User Storage (AUS) inside notification preferences, so favorites follow the signed-in user across devices instead of staying device-local only.

toggleWatchlistMarket is async (Promise<void>): it updates local state optimistically, emits favorite analytics, then read-merge-writes perps.watchlistMarkets for the active exchange (hyperliquid / myx) and current network. Failed remote writes revert local state. Unauthenticated users, missing preference blobs, and unmapped providers (e.g. aggregated) keep local-only behavior without throwing.

On init(), a non-blocking #syncWatchlistFromRemote hydrates local watchlistMarkets from AUS when remote data exists, or one-time migrates existing local lists into AUS when the blob exists but has no watchlist for that exchange. New export resolveWatchlistExchangeKey maps activeProvider to the AUS schema key.

Clients must allow AuthenticatedUserStorageService:getNotificationPreferences and putNotificationPreferences on the Perps controller messenger. Tests cover optimistic updates, merge writes, revert on PUT failure, aggregated skip, and init hydration/migration.

Reviewed by Cursor Bugbot for commit 4b926a3. Bugbot is set up for automated code reviews on this repo. Configure here.

@gambinish gambinish changed the title feat: aus watchlist init feat: AUS Perps Watchlist Jun 4, 2026
Comment thread packages/perps-controller/src/PerpsController.ts
@gambinish

Copy link
Copy Markdown
Member Author

@metamaskbot publish-previews

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.2-preview-7bc7196a6
@metamask-previews/accounts-controller@39.0.1-preview-7bc7196a6
@metamask-previews/address-book-controller@7.1.2-preview-7bc7196a6
@metamask-previews/ai-controllers@0.7.0-preview-7bc7196a6
@metamask-previews/analytics-controller@1.1.1-preview-7bc7196a6
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-7bc7196a6
@metamask-previews/announcement-controller@8.1.0-preview-7bc7196a6
@metamask-previews/app-metadata-controller@2.0.1-preview-7bc7196a6
@metamask-previews/approval-controller@9.0.2-preview-7bc7196a6
@metamask-previews/assets-controller@8.3.3-preview-7bc7196a6
@metamask-previews/assets-controllers@108.6.0-preview-7bc7196a6
@metamask-previews/authenticated-user-storage@2.0.0-preview-7bc7196a6
@metamask-previews/base-controller@9.1.0-preview-7bc7196a6
@metamask-previews/base-data-service@0.1.3-preview-7bc7196a6
@metamask-previews/bridge-controller@75.0.0-preview-7bc7196a6
@metamask-previews/bridge-status-controller@72.1.0-preview-7bc7196a6
@metamask-previews/build-utils@3.0.4-preview-7bc7196a6
@metamask-previews/chain-agnostic-permission@1.6.1-preview-7bc7196a6
@metamask-previews/chomp-api-service@3.1.0-preview-7bc7196a6
@metamask-previews/claims-controller@0.5.3-preview-7bc7196a6
@metamask-previews/client-controller@1.0.1-preview-7bc7196a6
@metamask-previews/compliance-controller@2.1.0-preview-7bc7196a6
@metamask-previews/composable-controller@12.0.1-preview-7bc7196a6
@metamask-previews/config-registry-controller@0.4.1-preview-7bc7196a6
@metamask-previews/connectivity-controller@0.2.0-preview-7bc7196a6
@metamask-previews/controller-utils@12.1.1-preview-7bc7196a6
@metamask-previews/core-backend@6.3.3-preview-7bc7196a6
@metamask-previews/delegation-controller@3.0.2-preview-7bc7196a6
@metamask-previews/earn-controller@12.2.0-preview-7bc7196a6
@metamask-previews/eip-5792-middleware@3.0.4-preview-7bc7196a6
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-7bc7196a6
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-7bc7196a6
@metamask-previews/ens-controller@19.1.3-preview-7bc7196a6
@metamask-previews/eth-block-tracker@15.0.1-preview-7bc7196a6
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-7bc7196a6
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-7bc7196a6
@metamask-previews/foundryup@1.0.1-preview-7bc7196a6
@metamask-previews/gas-fee-controller@26.2.2-preview-7bc7196a6
@metamask-previews/gator-permissions-controller@4.2.0-preview-7bc7196a6
@metamask-previews/geolocation-controller@0.1.3-preview-7bc7196a6
@metamask-previews/json-rpc-engine@10.5.0-preview-7bc7196a6
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-7bc7196a6
@metamask-previews/keyring-controller@27.0.0-preview-7bc7196a6
@metamask-previews/logging-controller@8.0.2-preview-7bc7196a6
@metamask-previews/message-manager@14.1.2-preview-7bc7196a6
@metamask-previews/messenger@1.2.0-preview-7bc7196a6
@metamask-previews/messenger-cli@0.2.0-preview-7bc7196a6
@metamask-previews/money-account-balance-service@1.0.2-preview-7bc7196a6
@metamask-previews/money-account-controller@0.3.3-preview-7bc7196a6
@metamask-previews/money-account-upgrade-controller@2.0.4-preview-7bc7196a6
@metamask-previews/multichain-account-service@10.0.3-preview-7bc7196a6
@metamask-previews/multichain-api-middleware@3.1.3-preview-7bc7196a6
@metamask-previews/multichain-network-controller@3.1.3-preview-7bc7196a6
@metamask-previews/multichain-transactions-controller@7.1.1-preview-7bc7196a6
@metamask-previews/name-controller@9.1.2-preview-7bc7196a6
@metamask-previews/network-controller@32.0.0-preview-7bc7196a6
@metamask-previews/network-enablement-controller@5.3.0-preview-7bc7196a6
@metamask-previews/notification-services-controller@24.1.3-preview-7bc7196a6
@metamask-previews/passkey-controller@2.0.1-preview-7bc7196a6
@metamask-previews/permission-controller@13.1.1-preview-7bc7196a6
@metamask-previews/permission-log-controller@5.1.0-preview-7bc7196a6
@metamask-previews/perps-controller@8.0.0-preview-7bc7196a6
@metamask-previews/phishing-controller@17.2.0-preview-7bc7196a6
@metamask-previews/polling-controller@16.0.6-preview-7bc7196a6
@metamask-previews/preferences-controller@23.1.0-preview-7bc7196a6
@metamask-previews/profile-metrics-controller@3.2.0-preview-7bc7196a6
@metamask-previews/profile-sync-controller@28.1.1-preview-7bc7196a6
@metamask-previews/ramps-controller@14.1.1-preview-7bc7196a6
@metamask-previews/rate-limit-controller@7.0.1-preview-7bc7196a6
@metamask-previews/react-data-query@0.2.1-preview-7bc7196a6
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-7bc7196a6
@metamask-previews/sample-controllers@5.0.1-preview-7bc7196a6
@metamask-previews/seedless-onboarding-controller@10.0.2-preview-7bc7196a6
@metamask-previews/selected-network-controller@26.1.3-preview-7bc7196a6
@metamask-previews/shield-controller@5.1.2-preview-7bc7196a6
@metamask-previews/signature-controller@39.2.5-preview-7bc7196a6
@metamask-previews/snap-account-service@0.3.1-preview-7bc7196a6
@metamask-previews/social-controllers@2.2.1-preview-7bc7196a6
@metamask-previews/storage-service@1.0.2-preview-7bc7196a6
@metamask-previews/subscription-controller@6.1.3-preview-7bc7196a6
@metamask-previews/transaction-controller@67.1.0-preview-7bc7196a6
@metamask-previews/transaction-pay-controller@23.4.0-preview-7bc7196a6
@metamask-previews/user-operation-controller@41.2.4-preview-7bc7196a6
@metamask-previews/wallet@3.0.0-preview-7bc7196a6

@gambinish gambinish marked this pull request as ready for review June 15, 2026 19:51
@gambinish gambinish requested review from a team as code owners June 15, 2026 19:51
* main: (497 commits)
  Release/1053.0.0 (#9195)
  Revert @metamask/transaction-pay-controller changes not required (#9194)
  chore: add discovery event names (#9178)
  chore: deprecate CurrencyRateController (#9182)
  Release/1052.0.0 (#9188)
  fix: getQuoteUser function is broken if request is not postQuote (#9187)
  fix(network-controller): Remove deprecated NetworkControllerGetNetworkConfigurationByNetworkClientId type (#9185)
  fix(network-controller): Remove MegaETH v1 default configuration (#9183)
  Release/1051.0.0 (#9181)
  fix: MM Pay transaction with isQuoteRequired that have same source and destination chain and token (#9150)
  Release/1050.0.0 (#9180)
  fix(network-controller): Only consider failover endpoints when using Infura (#9125)
  feat(assets-controllers): add isDeprecated to multichain controllers (#9044)
  refactor(smart-transactions-controller): import AuthenticationController namespace (#9167)
  Release 1049.0.0 (#9177)
  fix(transaction-pay-controller): vault musd via sentinel (#9161)
  Release 1048.0.0 (#9174)
  chore: remove orphaned semver.sh helper (#9172)
  fix(rpc-service): Consider all Infura HTTP errors as service failures except 400 and 429 (#9123)
  chore: remove outdated migrate-tags guide (#9171)
  ...

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a5c5a19. Configure here.

Comment thread packages/perps-controller/src/PerpsController.ts
Comment thread packages/perps-controller/src/PerpsController.ts
Comment thread packages/perps-controller/src/PerpsController.ts
await this.messenger.call(
'AuthenticatedUserStorageService:putNotificationPreferences',
nextPrefs,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concurrent toggles lose watchlist updates

Medium Severity

Each toggle performs its own GET-merge-PUT without coordinating with other in-flight toggles. Rapid successive calls can read the same remote snapshot and the last write wins, so an earlier optimistic change may never reach AUS even though the UI already updated.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a5c5a19. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants